<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改页面</title>
</head>
<body>
<h1>修改球员信息</h1>
<form action="update" method="POST">
    <input name="pid" type="hidden" value="${players.pid}">
    <p>
        球员姓名：<input name="pname" type="text" value="${players.pname}">
    </p>
    <p>
        出生时间：<input name="birthday" type="date" value="<fmt:formatDate value='${players.birthday}' pattern='yyyy-MM-dd' />">
    </p>
    <p>
        球员身高：<input name="height" type="text" value="${players.height}">
    </p>
    <p>
        球员体重：<input name="weight" type="text" value="${players.weight}"/>
    </p>
    <p>
        球员位置：
        <input type="radio" name="position" value="控球后卫">控球后卫
        <input type="radio" name="position" value="得分后卫">得分后卫
        <input type="radio" name="position" value="小前锋">小前锋
        <input type="radio" name="position" value="大前锋">大前锋
        <input type="radio" name="position" value="中锋">中锋
    </p>
    <p>
        所属球队：
        <select name="cid">
            <option value="0">--请选择--</option>
            <option value="1">湖人</option>
            <option value="2">火箭</option>
            <option value="3">凯尔特人</option>
            <option value="4">骑士</option>
            <option value="5">马刺</option>
            <option value="6">魔术</option>
            <option value="7">太阳</option>
            <option value="8">勇士</option>
        </select>
    </p>
    <p>
        <input type="submit" value="修改">
    </p>
</form>

</body>
<script type="text/javascript" src="${pageContext.request.contextPath}/statics/js/jquery.js"></script>
<script>

    $(function(){
        let position = ${players.position};
        console.log(position)
        if(position == '控球后卫'){
            $("input[name='position'][value='控球后卫']").prop('checked', true);
        } else if (position == '得分后卫'){
            $("input[name='position'][value='得分后卫']").prop('checked', true);
        } else if (position == '小前锋'){
            $("input[name='position'][value='小前锋']").prop('checked', true);
        } else if (position == '大前锋'){
            $("input[name='position'][value='大前锋']").prop('checked', true);
        } else if (position == '中锋'){
            $("input[name='position'][value='中锋']").prop('checked', true);
        }


        let cid=parseInt('${players.cid}');
        if(cid == 0){
            $("input[name='position'][value='0']").val('--请选择--');
        } else if (cid == 1){
            $("input[name='position'][value='1']").val('湖人');
        } else if (cid == 2){
            $("input[name='position'][value='2']").val('火箭');
        } else if (cid == 3){
            $("input[name='position'][value='3']").val('凯尔特人');
        } else if (cid == 4){
            $("input[name='position'][value='4']").val('骑士');
        } else if (cid == 5){
            $("input[name='position'][value='5']").val('马刺');
        } else if (cid == 6){
            $("input[name='position'][value='6']").val('魔术');
        } else if (cid == 7){
            $("input[name='position'][value='7']").val('太阳');
        } else if (cid == 8){
            $("input[name='position'][value='8']").val('勇士');
        }
    })
</script>
</html>
